﻿using ServerBase.Config;
using SvGame.Objects;
using static System.Net.Mime.MediaTypeNames;

namespace SvGame.Logic;

public static partial class GameLogic
{
    public static void PlayerLoginEnterRoom(this Player player)
    {
        //一般初始化
        if (!GetRoom(player.RoomUid, out var room))
        {
            room = BornRoom;
        }
        player.RoomIn(room);
    }
    //离开房间
    public static void RoomOut(this Player player)
    {
        var room = player.Room;
        room.DictPlayer.Remove(player.Puid);

        // 清空对手
        player.FightRemoveAll();
    }
    //进入房间
    public static void RoomIn(this Player player, Room room)
    {
        player.Room = room;
        player.RoomUid = room.Uid;

        room.DictPlayer[player.Puid] = player;
    }
    // 进入房间
    public static bool Move(this Player player, Room room)
    {
        player.RoomOut();
        player.RoomIn(room);

        player.RoomInfo();

        player.RoomInit();

        return true;
    }
    // 移动到房间
    public static bool RoomGo(this Player player, Room room, string movedir)
    {
        player.Room.Message($"{player.Name}往{ChineseDir(movedir)}离开。", player);
        room.Message($"{player.Name}从{ChineseDir(movedir.OppExit())}面走了过来。");

        return player.Move(room);
    }

}
